<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/4/11
 * Time: 15:39
 */

namespace Admin\Controller;


use Org\Net\IpLocation;
use Think\Controller;
use Think\Image;
use Think\Verify;

class TestController extends BaseController
{
	public function test()
	{
		echo 'hellow world' . '<br>';
//		$this->display('test1');
		$var = date('Y-m-d H:i:s', time());
		$this->assign('var', $var);
		$this->display();
	}

	public function index()
	{
		echo '11111';
		echo U('index');// /index.php/Admin/Test/index.html
	}

	public function test1()
	{
		echo U('index');/// index.php/Admin/Test/index.html
	}

	public function test2()
	{
//		echo U('Index/index');/// index.php/Admin/Index/index.html
		$this->display('Demo/test');
	}

	public function test3()
	{
		echo U('Index/index', array('id' => 100));// index.php/Admin/Index/index/id/100.html
	}

	public function test4()
	{
		$this->success('操作成功', U('Index/index'), 7000);
	}

	public function test5()
	{
		$this->error('操作失败', U('Index/index'), 7000);
	}

	public function test6()
	{
//		echo __MODULE__.'<br>';
//		echo __CONTROLLER__.'<br>';
//		echo __ACTION__.'<br>';
//		echo __PUBLIC__.'<br>';
//		echo __SELF__.'<br>';
		$this->display();
	}

	public function test8()
	{
		$array = array('西游记', '三个女人和105个男人的故事',
			'一个男人和一堆女人的故事', '三国演义');
		$array2 = array(array('01', '02', '03'),
			array('11', '12', '13'), array('21', '22', '23'), array('31', '32', '33'));
		$this->assign('ar', $array);
		$this->assign('array2', $array2);
		$this->display();

	}

	public function test9()
	{
		$stu = new Student();
		dump($stu);
		$stu->id = 100;
		$stu->name = '我是内坑第一壮';
		$stu->sex = '男';
//		dump($stu);
		dump($stu);
		$this->assign('stu', $stu);
		$this->display();
	}

	public function test10()
	{
		$this->display();
	}

	public function test11()
	{
		$time = time();
		$str = 'adbcdefghiijgk';
		$this->assign('str', $str);
		$this->assign('time', $time);
		$this->display();
	}

	public function test12()
	{
		$sign = '';
		$this->assign('sign', $sign);
		$this->display();
	}

	public function test13()
	{
		$a = 100;
		$b = 10;
		$this->assign('a', $a);
		$this->assign('b', $b);
		$this->display();

	}

	public function body()
	{
		$this->display();
	}

	public function head()
	{
		$this->display();
	}

	public function foot()
	{
		$this->display();
	}

	public function test14()
	{
		$array1 = array('西游记', '三个女人和105个男人的故事',
			'一个男人和一堆女人的故事', '三国演义');
		$array2 = array(array('00', '01',
			'02', '03'), array('10', '11',
			'12', '13'), array('20', '21',
			'22', '23'));
		$this->assign('array1', $array1);
		$this->assign('array2', $array2);
		$this->display();

	}

	public function test15()
	{
		$day = date('N', time());
		$this->assign('day', $day);
		$this->display();
	}

	public function test16()
	{
		$this->display();
	}

	public function test17()
	{
		$model = M('Dept');
		$data = $model->select();
		dump($model->getLastSql());
		dump($model->_sql());
	}

	public function test18()
	{
		$model = M('Dept');
		$model->name = '技术部1111';
		$model->pid = '0';
		$model->sort = '10';
		$model->remark = '技术部门最重要11111';
//		$data = $model->add();
//		dump($data);
		dump($model->data());
//		dump($model);
	}

	public function test23()
	{
		$model = M('Dept');
		$model->where('id>10');
		$data = $model->select();
		dump($data);
	}

	public function test24()
	{
		$model = M('Dept');
		$model->where('id>5');
//		$data = $model->select();
		$model->limit(1, 4);
		$data = $model->select();
		dump($data);
	}

	public function test25()
	{
//		G:\PhpstormProjects\oa\Application\Admin\Controller
//		echo WORKING_PATH;
	}

	public function test28()
	{
		$model = M('Dept');
		$data = $model->field('name,count(*) as count')->group('name')->select();
		dump($data);
	}

	public function test29()
	{
		$model = M('Dept');
		$data = $model->count();
		dump($data);
	}

	public function test30()
	{
		$model = M('Dept');
		$data = $model->field('name,count(*) as count')->fetchSql(true)->group('name')->select();
		dump($data);
	}

	public function _empty()
	{
		echo '您好，您访问的' . ACTION_NAME . '不存在';

	}

	public function test35()
	{
		$model = D('Szphp');
		dump($model);
	}

	public function test36()
	{
		session('name', '内坑第一');
		session('name2', '内坑第二');
		cookie('name3', '啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊');
//		dump(session());
		dump($_SESSION);
		dump($_COOKIE);

	}

	public function test38()
	{
		gbk2utf8();
//		gbk2ut();
	}

	public function test39()
	{
		getInfo();
	}

	public function test40()
	{
		load('@/hello');
		sayhello('world');
	}

	public function test41()
	{
		//配置
		$cfg = array(
			'useZh' => true,           // 使用中文验证码
			'fontSize' => 20,              // 验证码字体大小(px)
			'useCurve' => false,            // 是否画混淆曲线
			'useNoise' => false,            // 是否添加杂点
			'length' => 4,               // 验证码位数
		);
		$verify = new Verify($cfg);
		$verify->entry();
	}

	public function test42()
	{
		$model = M();
		$result = $model->field('t1.*,t2.name as deptname')->table('sp_user as t1,sp_dept
		 as t2')->where('t1.dept_id = t2.id')->select();
		dump($result);
	}

	public function test43()
	{
		$model = new IpLocation('qqwry.bat');
//		dump($ip);die;
//		$ippp = I('"get.ip');
		$locate = $model->getlocation('110.85.22.147');
//		$result = get_client_ip(1);
		dump($locate);
	}

	public function test44()
	{
		$image = new Image();
//		dump(WORKING_PATH.'/1.png');die;
		$imag = $image->open(WORKING_PATH . '/1.png');
		// 返回图片的高度
		$height = $image->height();
		$type = $image->type();
		// 返回图片的类型
		//$mime = $image->mime();
// 返回图片的mime类型
		$size = $image->size();
		dump($imag);
	}
}